package com.bawei.carreading

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.FragmentPagerAdapter
import com.alibaba.android.arouter.facade.annotation.Route
import com.bawei.carreading.databinding.ActivityMainBinding
import com.bawei.common_module.base.BaseActivity
class MainActivity : BaseActivity<MainViewModel,ActivityMainBinding>(R.layout.activity_main) {

     override fun dataObserver() {

     }

     override fun initViews() {
         val fragments= mutableListOf(ShouyeFragment(),CheQuanFragment(),LookcarFragment(),BuycarFragment(),WodeFragment())
         binding.vp.adapter=object : FragmentPagerAdapter(supportFragmentManager){
             override fun getCount()=fragments.size

             override fun getItem(position: Int)=fragments[position]

             override fun getPageTitle(position: Int)= mutableListOf("首页","车圈儿","看车","买车","我的")[position]
         }
         //预加载
         binding.vp.offscreenPageLimit=fragments.size
         //绑定viewPage
         binding.tab.setupWithViewPager(binding.vp)
         binding.tab.getTabAt(0)?.setIcon(R.mipmap.a1)
         binding.tab.getTabAt(1)?.setIcon(R.mipmap.a2)
         binding.tab.getTabAt(2)?.setIcon(R.mipmap.a3)
         binding.tab.getTabAt(3)?.setIcon(R.mipmap.a4)
         binding.tab.getTabAt(4)?.setIcon(R.mipmap.a5)
     }

 }